<?php
require_once("../../class2.php");
require_once(HEADERF);
		$user_id = USERID;
		$user_name = USERNAME;
require_once("./includes/require_all.php");

ramka("open");

if (in_array(USERNAME,$mods,true)) {

	echo "<a href='http://playonbg.info/translations/' class='forumheader4' style='font-size:14px; margin-left:10px;'>НАЗАД</a><br>";
	echo "<center class='forumheader4' style='margin-top:-20px; margin-left:-1px; padding-bottom:6px;'><h1 style='border-bottom:0px;'>Активност</h1></center>";
	CMS_lastApprovedEcho();

	$limito=100;
	if(isset($_GET['page'])) { $page=$_GET['page']; $limi=$page*$limito; }
	else { $page=1; $limi=1; }
	
	$data= mysql_query("SELECT * FROM cms_ipact ORDER BY date DESC LIMIT $limi, $limito");
	
	function print_sections() { global $data;
							
		echo <<<HTML
				<div style="border: 0px solid #FFF; border-color: grey;">
				<table cellpadding='5' CELLSPACING='0' CELLPADDING ='4' WIDTH='100%'>
				<tr class="forumheader">
				<td class="textGREY" WIDTH=15%><b>Потребител</b></td>
				<td class="textGREY" WIDTH=73%><b>Посетил<b></td>
				<td class="textGREY" WIDTH=12%><b>Преди<b></td>
				</tr>
HTML;
		$a= 0; $num=0;
		while ($v=mysql_fetch_array($data)) {
			if ($v['username']=='USERNAME') {
				$v['username']="Гост";
			}
			echo "<tr class='forumheader3'>";
			echo "<td class='textWHITE'>".$v['username']."</td>";
			echo "<td>".$v['visited']."</td>";
			$time = time()-strtotime($v['date']);
			if($time < 60){
				echo "<td>".$time." секунди</td>";
			}
			elseif($time < 3600 and $time >= 60){
				echo "<td>".floor(($time)/60)." минути</td>";
			}
			elseif($time < 86400 and $time >= 3600){
				echo "<td>".floor(($time)/3600)." часа</td>";
			}
			elseif($time < 31536000 and $time >= 86400){
				echo "<td>".floor(($time)/86400)." дни</td>";
			}
			else{
				echo "<td>".floor(($time)/31536000)." години</td>";
			}
			echo "</tr>";
			$num++;
		}
		echo "</table>";}

	print_sections();

	echo "</div>";
	
	$allacts=mysql_fetch_array(mysql_query("SELECT COUNT(id) as count FROM cms_ipact"));
	$allpages= round($allacts['count']/$limito);
	$onewaypages= 10;
	if($page-$onewaypages<=0){
		$startpage= 1;
		$addtoright= $onewaypages-$page;
	} else $startpage= $page-$onewaypages;
	if($page+$onewaypages+$addtoright<=$allpages){
		$endpage=$page+$onewaypages+$addtoright;
	} else $endpage=$allpages;
	echo "<center class='forumheader'>";
	for($startpage;$startpage<=$endpage;$startpage++){
		if($startpage!=$page) {
			echo "<a href='ipact.php?page=$startpage' class='button textWHITE'>$startpage</a>";
		} else echo "<span class='button textRED'>$page</span>";
	}
	echo "</center>";
	
	CMS_activitySave("ipact.php");
}
else echo "<meta http-equiv=\"refresh\" content=\"0;http://playonbg.info\" />";

ramka("close");

require_once(FOOTERF);
?>